package com.ap.core.validation.message.rules;

import com.ap.core.dao.FinancialInstitutionDao;
import com.ap.core.domain.FinancialInstitution;
import com.ap.core.message.managepayment.info.ConfirmPaymentRequestMessageInfo;
import com.ap.core.validation.message.info.MessageValidationInfo;
import com.ap.core.validation.message.info.RTPOriginalInfoForConfirmPayment;
import com.ap.core.validation.rules.AbstractValidationRule;

/**
 * User:Rohit.Dixit
 * The element Total Payment Request Amount must be valid with its associated order Payment amount.
 */
public class RV0015Rule extends AbstractValidationRule<MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment>> {

	  private FinancialInstitutionDao financialInstitutionDao;
	  private FinancialInstitution financialInstitution;
	@Override
	public boolean validate(MessageValidationInfo<ConfirmPaymentRequestMessageInfo, RTPOriginalInfoForConfirmPayment> infoObject) {
		
		financialInstitution = financialInstitutionDao.findById(infoObject.getOriginalInfo().getFIid());
		
	    return financialInstitution !=null && financialInstitution.getFiIdentification().equals(infoObject.getBoundObject().getConsumerAcct().getFIId());
		
	}
	
	 public void setFinancialInstitutionDao(FinancialInstitutionDao financialInstitutionDao) {
	        this.financialInstitutionDao = financialInstitutionDao;
	    }

}

